import 'package:flutter/material.dart';
import 'package:ichinesereader/themes/appTheme.dart';
import 'package:get/get.dart';
import 'package:sidebarx/sidebarx.dart';

class PageStyles {
  EdgeInsets teacherReportMainContainerPageEdgeInsets() {
    return const EdgeInsets.fromLTRB(0.0, 0.0, 12.0, 0.0);
  }

  EdgeInsets mainContainerPageEdgeInsets() {
    return const EdgeInsets.fromLTRB(0.0, 30.0, 12.0, 30.0);
  }

  EdgeInsets mainContainerWithPaginationEdgeInsets() {
    return const EdgeInsets.fromLTRB(0.0, 30.0, 12.0, 8.0);
  }

  EdgeInsets sideBarPageEdgeInsets() {
    return const EdgeInsets.fromLTRB(12.0, 30.0, 12.0, 30.0);
  }

  EdgeInsets gridEdgeInsets() {
    return const EdgeInsets.fromLTRB(12.0, 30.0, 12.0, 30.0);
  }

  //以学生页面library为准
  EdgeInsets pageEdgeInsets() {
    return const EdgeInsets.fromLTRB(12.0, 18.0, 0.0, 0.0);
  }

  EdgeInsets pageEdgeInsetsAllWith(double x) {
    return EdgeInsets.all(x);
  }

  BoxDecoration choiceChipPageEdgeInsets() {
    return BoxDecoration(
      borderRadius: BorderRadius.circular(3.0),
      color: Get.isDarkMode
          ? AppTheme.colors.darkTheme2
          : Colors.white.withOpacity(0.3),
    );
  }

  BoxDecoration dataGridForground() {
    return Get.isDarkMode
        ? BoxDecoration(
            color: AppTheme.colors.darkTheme2,
          )
        : BoxDecoration(
            color: Colors.white,
          );
  }

  BoxDecoration dataGridBackground() {
    return BoxDecoration(
      color: Get.isDarkMode
          ? AppTheme.colors.darkTheme1
          : Colors.white.withOpacity(0.3),
      borderRadius: BorderRadius.circular(3.0),
    );
  }

  BoxDecoration pageBoxDecoration() {
    return Get.isDarkMode
        ? BoxDecoration(
            color: Colors.black,
          )
        : BoxDecoration(
            gradient: LinearGradient(
              colors: [
                Get.theme.primaryColorDark,
                AppTheme.colors.primary,
                AppTheme.colors.babyBlue,
                Get.theme.primaryColorLight,
              ],
              begin: Alignment.topLeft,
              end: Alignment(2.0, 1.0),
            ),
          );
  }

//reporty Inkwell
  BoxDecoration reportInkwellBoxDecoration() {
    return Get.isDarkMode
        ? BoxDecoration(
            color: Colors.black,
            borderRadius: BorderRadius.circular(30.0),
            border: Border.all(width: 3.0, color: Colors.grey),
          )
        : BoxDecoration(
            gradient: LinearGradient(
              colors: [
                Get.theme.primaryColorDark,
                Get.theme.primaryColor,
                Get.theme.primaryColorDark,
              ],
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
            ),
            borderRadius: BorderRadius.circular(9.0),
            boxShadow: [
              BoxShadow(
                blurRadius: 6,
                spreadRadius: 1,
                color: Get.isDarkMode
                    ? Color(0xff333333)
                    : Colors.black.withOpacity(0.1),
                offset: Offset(3, 1),
              ),
            ],
            border: Border.all(
              width: 4.0,
              color: Get.theme.primaryColor.withOpacity(0.6),
            ),
          );
  }

  BoxDecoration pageTitleBoxDecoration() {
    return BoxDecoration(
      color: Get.isDarkMode ? Colors.black : Colors.white.withOpacity(0.3),
      borderRadius: BorderRadius.circular(3),
      boxShadow: [
        BoxShadow(
          blurRadius: 9,
          spreadRadius: 1,
          color: Get.isDarkMode
              ? Color(0xff333333)
              : Colors.black.withOpacity(0.1),
          offset: Offset(3, 3),
        ),
      ],
    );
  }

  BoxDecoration pageSidebarDecoration() {
    return BoxDecoration(
      color: Get.isDarkMode
          ? AppTheme.colors.darkTheme2
          : Colors.black.withOpacity(0.1),
      borderRadius: BorderRadius.circular(6.0),
    );
  }

  SidebarXTheme pageSidebarXTheme() {
    return SidebarXTheme(
      margin: const EdgeInsets.all(3.0),
      selectedItemMargin: const EdgeInsets.all(3.0),
      itemPadding: const EdgeInsets.all(0.8),
      selectedItemPadding: const EdgeInsets.all(0.8),
      decoration: BoxDecoration(
        color: Colors.transparent,
        borderRadius: BorderRadius.circular(3.0),
      ),
      hoverColor: Get.theme.primaryColor.withOpacity(0.6),
      textStyle: TextStyle(
          fontFamily: 'Montserrat', color: Colors.white.withOpacity(0.7)),
      selectedTextStyle:
          const TextStyle(fontFamily: 'Montserrat', color: Colors.white),
      itemTextPadding: const EdgeInsets.only(left: 10),
      selectedItemTextPadding: const EdgeInsets.only(left: 10),
      itemDecoration: BoxDecoration(
        borderRadius: BorderRadius.circular(3.0),
        //border: Border.all(color: canvasColor),
      ),
      selectedItemDecoration: BoxDecoration(
        color: Get.theme.primaryColorDark.withOpacity(0.1),
        borderRadius: BorderRadius.circular(1),
        border: Border.all(
          color: Colors.white.withOpacity(0.3),
        ),
        // gradient: const LinearGradient(
        //   colors: [accentCanvasColor, canvasColor],
        // ),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.1),
            blurRadius: 3,
          )
        ],
      ),
      iconTheme: IconThemeData(
        color: Colors.white.withOpacity(0.7),
        size: 20,
      ),
      selectedIconTheme: const IconThemeData(
        color: Colors.white,
        size: 20,
      ),
    );
  }

//SIDEBAR
  SidebarXTheme pageSidebarXExtendTheme() {
    return SidebarXTheme(
      width: 200,
      margin: const EdgeInsets.all(3.0),
      selectedItemMargin: const EdgeInsets.all(3.0),
      itemPadding: const EdgeInsets.all(0.8),
      selectedItemPadding: const EdgeInsets.all(0.8),
      decoration: BoxDecoration(
        color: Colors.transparent,
        borderRadius: BorderRadius.circular(3.0),
      ),
      hoverColor: Get.theme.primaryColor,
      textStyle: TextStyle(
          fontFamily: 'Montserrat', color: Colors.white.withOpacity(0.7)),
      selectedTextStyle:
          const TextStyle(fontFamily: 'Montserrat', color: Colors.white),
      itemTextPadding: const EdgeInsets.only(left: 10),
      selectedItemTextPadding: const EdgeInsets.only(left: 10),
      itemDecoration: BoxDecoration(
        borderRadius: BorderRadius.circular(4),
        //border: Border.all(color: canvasColor),
      ),
      selectedItemDecoration: BoxDecoration(
        color: Get.isDarkMode
            ? Get.theme.primaryColor
            : Get.theme.primaryColorDark,
        borderRadius: BorderRadius.circular(6.0),
        border: Border.all(
          color: Colors.white.withOpacity(0.6),
        ),
        // gradient: const LinearGradient(
        //   colors: [accentCanvasColor, canvasColor],
        // ),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.1),
            blurRadius: 9,
          )
        ],
      ),
      iconTheme: IconThemeData(
        color: Colors.white.withOpacity(0.7),
        size: 16,
      ),
      selectedIconTheme: const IconThemeData(
        color: Colors.white,
        size: 16,
      ),
    );
  }

//TAB BAR
  TabBar buildTabBar(List<String> tabNames) {
    return TabBar(
      labelColor: Get.isDarkMode
          ? Get.theme.primaryColorDark
          : Get.theme.primaryColorLight,
      //unselectedLabelColor: Get.isDarkMode ? Get.theme.primaryColorDark : null,
      indicator: BoxDecoration(
        color: Get.isDarkMode ? Colors.black : AppTheme.colors.purpleBtn,
        borderRadius: BorderRadius.circular(3.0),
        boxShadow: Get.isDarkMode
            ? null
            : [
                BoxShadow(
                  blurRadius: 3,
                  spreadRadius: 1,
                  color: Get.isDarkMode
                      ? Colors.transparent
                      : Colors.black.withOpacity(0.2),
                  offset: Offset(1, 1),
                ),
              ],
      ),
      indicatorSize: TabBarIndicatorSize.label,
      tabs: tabNames
          .map((tab) => Padding(
                padding: const EdgeInsets.symmetric(
                  horizontal: 30.0,
                  vertical: 6.0,
                ),
                child: Tab(
                  text: tab.tr,
                  height: 24,
                ),
              ))
          .toList(),
    );
  }

  TabBar buildTabBarWithContoller(
      List<String> tabNames, TabController controller) {
    return TabBar(
      labelColor: Get.isDarkMode ? Get.theme.primaryColorDark : Colors.white,
      controller: controller,
      indicator: BoxDecoration(
        color: Get.isDarkMode ? Colors.black : AppTheme.colors.purpleBtn,
        borderRadius: BorderRadius.circular(3.0),
        boxShadow: Get.isDarkMode
            ? null
            : [
                BoxShadow(
                  blurRadius: 3,
                  spreadRadius: 1,
                  color: Get.isDarkMode
                      ? Colors.transparent
                      : Colors.black.withOpacity(0.2),
                  offset: Offset(1, 1),
                ),
              ],
      ),
      indicatorSize: TabBarIndicatorSize.label,
      tabs: tabNames
          .map((tab) => Padding(
                padding: const EdgeInsets.symmetric(
                  horizontal: 18.0,
                  vertical: 6.0,
                ),
                child: Tab(
                  text: tab.tr,
                  height: 24,
                ),
              ))
          .toList(),
    );
  }
}
